home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes ƒ / Circular wipe.c < prev    next >
Text File  |  1994-04-15  |  4KB  |  124 lines

  1. /**********************************************************************\
  2.  
  3. File:        Circular wipe.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short CircularWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* Trace a region from the center to the topleft corner, over <BlockSize> pixels,
  34.    and back to the center.  Fill that in and move the region parameters +BlockSize.
  35.    Repeat for all sides. */
  36.  
  37. pascal short CircularWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  38. {
  39.     RgnHandle    curregion;
  40.     int            cx,cy,lastx,lasty;
  41.     int            BlockSize;
  42.     
  43.     BlockSize=theWindowWidth/40;
  44.     cx = boundsRect.left + theWindowWidth / 2;
  45.     cy = boundsRect.top + theWindowHeight / 2;
  46.  
  47.     curregion=NewRgn();
  48.     lastx=boundsRect.left;
  49.     do                                            /* top quadrant */
  50.     {
  51.         StartTiming();
  52.         SetEmptyRgn(curregion);
  53.         MoveTo(cx,cy);
  54.         OpenRgn();
  55.             LineTo(lastx,boundsRect.top);
  56.             Line(BlockSize,0);
  57.             LineTo(cx,cy);
  58.         CloseRgn(curregion);
  59.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  60.             &boundsRect, &boundsRect, 0, curregion);
  61.         lastx+=BlockSize;
  62.         TimeCorrection(CorrectTime);
  63.     }
  64.     while (lastx<boundsRect.right);
  65.     
  66.     lasty=boundsRect.top;
  67.     do                                            /* right quadrant */
  68.     {
  69.         StartTiming();
  70.         SetEmptyRgn(curregion);
  71.         MoveTo(cx,cy);
  72.         OpenRgn();
  73.             LineTo(boundsRect.right,lasty);
  74.             Line(0,BlockSize);
  75.             LineTo(cx,cy);
  76.         CloseRgn(curregion);
  77.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  78.             &boundsRect, &boundsRect, 0, curregion);
  79.         lasty+=BlockSize;
  80.         TimeCorrection(CorrectTime);
  81.     }
  82.     while (lasty<boundsRect.bottom);
  83.     
  84.     lastx=boundsRect.right;
  85.     do                                            /* bottom quadrant */
  86.     {
  87.         StartTiming();
  88.         SetEmptyRgn(curregion);
  89.         MoveTo(cx,cy);
  90.         OpenRgn();
  91.             LineTo(lastx,boundsRect.bottom);
  92.             Line(-BlockSize, 0);
  93.             LineTo(cx,cy);
  94.         CloseRgn(curregion);
  95.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  96.             &boundsRect, &boundsRect, 0, curregion);
  97.         lastx-=BlockSize;
  98.         TimeCorrection(CorrectTime);
  99.     }
  100.     while (lastx>boundsRect.left-BlockSize);
  101.     
  102.     lasty=boundsRect.bottom;
  103.     do                                            /* left quadrant */
  104.     {
  105.         StartTiming();
  106.         SetEmptyRgn(curregion);
  107.         MoveTo(cx,cy);
  108.         OpenRgn();
  109.             LineTo(boundsRect.left,lasty);
  110.             Line(0, -BlockSize);
  111.             LineTo(cx,cy);
  112.         CloseRgn(curregion);
  113.         CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  114.             &boundsRect, &boundsRect, 0, curregion);
  115.         lasty-=BlockSize;
  116.         TimeCorrection(CorrectTime);
  117.     }
  118.     while (lasty>boundsRect.top-BlockSize);
  119.     
  120.     DisposeRgn(curregion);
  121.     
  122.     return 0;
  123. }
  124.